package cn.schoolwow.quickdao.test.module.business.user.dml.user.flow.add;

import cn.schoolwow.quickdao.domain.DAO;
import cn.schoolwow.quickdao.test.entity.User;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import org.junit.Assert;

import java.util.List;

public class CheckAddUserResultFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        DAO dao = flowContext.checkInstanceData(DAO.class);

        dao.addRecordString("查询用户结果并比对");
        List<User> userList = dao.query(User.class)
                .orderBy("id")
                .execute()
                .getList();
        Assert.assertEquals(11,userList.size());

        for(int i=0;i<11;i++){
            User user = userList.get(i);

            Assert.assertEquals("user"+i, user.getUsername());
            Assert.assertEquals("123456", user.getPassword());
            Assert.assertEquals("user"+i+"@fake.com", user.getEmail());
        }
    }

    @Override
    public String name() {
        return "检查添加用户结果";
    }

}
